using System.Drawing;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
/*
public class loadgif : MonoBehaviour
{
    public List<Sprite> _gifFrames;
    public float _period;
    public int _frameIndex;

    void Awake()
    {
        ExtractGIFTOList(Application.streamingAssetsPath + "/load_in.gif", _gifFrames);
       _period = _frameIndex = 0;
    }
    public static void ExtractGIFTOList(string gifPath,List<Sprite> gifFrames)
    {
        Image gif = Image.FromFile(gifPath);
        FrameDimension dimension = new FrameDimension(gif.FrameDimensionsList[0]);
        int framCount = gif.GetFrameCount(dimension);
        for(int i = 0; i < framCount; i++)
        {
            gif.SelectActiveFrame(dimension,i);
            Bitmap frame = new Bitmap(gif.Width, gif.Height);
            System.Drawing.Graphics.FromImage(frame).DrawImage(gif, Point.Empty);
            Texture2D frameTexture = new Texture2D(frame.Width, frame.Height);
            for(int x=0;x<frame.Width;x++)
                for(int y = 0; y< frame.Height; y++)
                {
                    var sourceColor = frame.GetPixel(x, y);
                    frameTexture.SetPixel(x, frame.Height - 1 - y, new Color32(sourceColor.R, sourceColor.G, sourceColor.B, sourceColor.A));
                }
            frameTexture.Apply();
            Sprite sprite = Sprite.Create(frameTexture, new Rect(0, 0, frameTexture.width, frameTexture.height), Vector2.one * 0.5f);
            gifFrames.Add(sprite);
        }
    }
    private void Update()
    {
        int lisLen = _gifFrames.Count;
        var sprite = this.GetComponent<SpriteRenderer>();
        if (++_period > 3)
        {
            _period = 0;
            _frameIndex++;
        }
    }

    //void OnGUI()
    //{
    //    //GUI.DrawTexture(new Rect(drawPosition.x, drawPosition.y, gifFrames[0].width, gifFrames[0].height), gifFrames[(int)(Time.frameCount * speed) % gifFrames.Count]);
    //}
}
*/